Repository navigation
fix(import): tolerate common file variations and say where a file breaks (#19) - #67
Merged
Merged
Conversation
…aks (#19) #19 reported import errors on files their author considered standard, with no sample files. Probing the BeerXML parser showed a single odd value failed the whole import with an unlocated serde message: a decimal comma ("5,5"), lowercase or upper-case enum values ("boil"), common synonyms ("Whirlpool", "Malt"), or a hop without <ALPHA>. BeerJSON imports only reported Ajv's first error, often a combinator ("must match a schema in anyOf") or a property-less "must NOT have additional properties". BeerXML (werb-beerxml, so also the CLI and the WASM import): - Numbers read a decimal comma; with a point present, commas are thousands separators. Failures say `not a number: "<raw>"`. - Enums go through LenientEnum: case, spacing and punctuation ignored, plus synonyms (Whirlpool / Hop stand / Flameout -> Aroma, Malt -> Grain, Whole / Cones -> Leaf, LME -> Extract...). Unknown values read as absent and the converter applies its default. - A missing hop ALPHA / AMOUNT, fermentable or misc AMOUNT reads as 0, like an empty element already did. - serde_path_to_error locates failures: Error::Invalid { location } with a 1-based XPath such as /RECIPES/RECIPE[1]/HOPS/HOP[2]/AMOUNT. JolieBulle JSON errors carry their field path too. BeerJSON (@werb/validate, used by file import and GitHub Pull): - stripNulls: null optional properties mean absent. - describeErrors: the deepest, most telling error, naming the missing or unknown property, or the value and the allowed ones. Tests: Rust (lenient values, located errors), validator unit tests, WASM import tests, BeerJSON import tests, e2e imports through the file picker.
# Conflicts: # CHANGELOG.md # apps/desktop/test/e2e/smoke.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #19. Doesn't close it: we still have no sample files from the reporter, so this covers what was reproducible without them.
Why
Probing the BeerXML parser showed one odd value failed the whole import with an unlocated serde message: a decimal comma (
5,5), a lowercase enum (boil), a common synonym (Whirlpool,Malt), or a hop without<ALPHA>. BeerJSON imports reported Ajv's first error, often a combinator or a property-less "must NOT have additional properties".BeerXML (
werb-beerxml: app import via WASM, and the CLI)not a number: "<raw>".LenientEnum: case, spacing and punctuation ignored, plus synonyms (Whirlpool / Hop stand / Flameout → Aroma, Malt → Grain, Whole / Cones → Leaf). Unknown values read as absent and the converter applies its default.ALPHA/AMOUNT, fermentable or miscAMOUNTread as 0, like an empty element already did.serde_path_to_errorlocates failures:Error::Invalid { location }with a 1-based XPath, e.g./RECIPES/RECIPE[1]/HOPS/HOP[2]/AMOUNT: not a number: "lots". JolieBulle JSON errors carry their field path.BeerJSON (
@werb/validate: file import and GitHub Pull)stripNulls:nulloptional properties mean absent.describeErrors: the deepest, most telling error, naming the missing or unknown property, or the value and the allowed ones.Tests
@werb/validate:stripNulls,describeErrors(enum, required, type).